package com.velpro.im.service.impl;

import java.util.List;

import javax.annotation.Resource;

import com.velpro.im.mapper.PartnerTypeMapper;
import com.velpro.im.mapper.po.PartnerType;
import com.velpro.im.service.PartnerTypeService;
import org.springframework.stereotype.Service;


 
@Service
public class PartnerTypeServiceImpl implements PartnerTypeService {

    @Resource
    private PartnerTypeMapper partnerTypeRepo;
   
	@Override
	public PartnerType get(Integer id) {
		return partnerTypeRepo.get(id);
	}

	@Override
	public List<PartnerType> list(String path,Boolean enabled) {
		return partnerTypeRepo.list(path,enabled);
	}

	@Override
	public int enable(int id, boolean enabled) {
		return partnerTypeRepo.enable(id, enabled);
	}

	@Override
	public int insert(PartnerType item) {
		int ret = partnerTypeRepo.insert(item);
		this.partnerTypeRepo.updatePath(item.getId());
		return ret;
	}

	@Override
	public int update(PartnerType item) {
		int ret = partnerTypeRepo.update(item);
		this.partnerTypeRepo.updatePath(item.getId());
		return ret;
	}

	@Override
	public int updateSeqNum(int id, int seqNum) {
		return partnerTypeRepo.updateSeqNum(id, seqNum);
	}

	@Override
	public int delete(int id) {
		/*PartnerType item = this.partnerTypeRepo.get(id);
		if(item == null){
			throw new ValException(JsMessage.ERR_CODE_ERROR,"参数错误!");
		}
		if(item.getParentId().intValue() == 0){
			throw new ValException(JsMessage.ERR_CODE_ERROR,"默认分类不能删除!");
		}
		int cnt = this.partnerTypeRepo.getSubListCnt(id, null);
		if(cnt > 0){
			throw new ValException(JsMessage.ERR_CODE_ERROR,"该分类下有子类不能删除!");
		}*/
		
		/*cnt = this.partnerInfoRepo.getCntByType(item.getId());
		if(cnt > 0){
			throw new ValException(JsMessage.ERR_CODE_ERROR,"该分类下有商家不能删除!");
		}*/
		return this.partnerTypeRepo.delete(id);
	}

	@Override
	public List<PartnerType> getDataByCategory(Integer category) {
	 
		return partnerTypeRepo.getDataByCategory(  category);
	}

	@Override
	public List<PartnerType> getParentList(Integer partnerId) {
		 
		return partnerTypeRepo.getParentList(  partnerId);
	}


	
}
